package com.xml.demo03;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

public class Test01 {
    public static void main(String[] args) throws Exception {
     /*   InputStream ras = Test01.class.getClassLoader().getResourceAsStream("dota.properties");
        Properties p=new Properties();
        p.load(ras);
        p.clone();
        String property = p.getProperty("className");
        Class<?> aClass = Class.forName(property);
        Constructor<?> dc = aClass.getDeclaredConstructor();
        dc.setAccessible(true);
        Object o = dc.newInstance();
        Method[] dm = aClass.getDeclaredMethods();
        BufferedWriter bw=new BufferedWriter(new FileWriter("zuoye.txt",true));
        int count = 0;
        for (Method method : dm) {
            try {
                if (method.isAnnotationPresent(MyTest.class)){
                    method.invoke(true);
                    method.invoke(o);
                }
            } catch (Exception e) {
               // e.printStackTrace();
                bw.write(method.getName()+"方法出现了异常");
                bw.newLine();
                Date d=new Date();
                SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss:SS");
                String format = sdf.format(d);
                bw.write("异常出现的时间"+format);
                bw.newLine();
                String simpleName = e.getCause().getClass().getSimpleName();
                bw.write("异常的名字"+simpleName);
                bw.newLine();
                String message = e.getCause().getMessage();
                bw.write("异常出现的原因"+message);
                bw.newLine();
                bw.flush();
                count++;
            }
        }
        bw.write("本次总共出现了"+count+"次");
        bw.newLine();
        bw.close();*/
    }
}
